import { useTabsStore } from '@/stores/tabs'
import { useTokenStore } from '@/stores/token'
import { useProfileStore } from '@/stores/profile'
import { useMenuStore } from '@/stores/menu'

export function loginResult(res: any) {
  const tokenStore = useTokenStore()
  const profileStore = useProfileStore()

  tokenStore.setToken(res.token)
  profileStore.setProfile({
    account: res.account,
    nickname: res.nickname,
    email: res.email,
  })
}

export function logoutResult() {
  const tokenStore = useTokenStore()
  const tabsStore = useTabsStore()
  const profileStore = useProfileStore()
  const menuStore = useMenuStore()

  tokenStore.removeToken()
  tabsStore.initTabs()
  profileStore.removeProfile()
  menuStore.removeAll()
}
